import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios'

Vue.use(ElementUI)
Vue.config.productionTip = false

// 配置axios
axios.defaults.baseURL = 'http://localhost:9999/api'
axios.interceptors.request.use(config => {
    const token = localStorage.getItem('token')
    if (token) {
        config.headers.Authorization = `Bearer ${token}`
    }
    return config
})

Vue.prototype.$http = axios

// 创建Vue实例之前先恢复状态
store.dispatch('restoreState')

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app') 